/**
 * SigninAction.java 1.0 2007-5-6 下午05:29:19,创建 by yangfan
 */


package org.in4j.bbs.action.user;

import java.sql.Timestamp;

import org.in4j.bbs.action.AbstractAction;
import org.in4j.bbs.model.OnlineInfo;
import org.in4j.bbs.model.User;
import org.in4j.bbs.service.UserService;

/**
 * 用户登录
 * @author yangfan
 * @version 1.0 2007-5-6 下午05:29:19,创建
 */
public class SigninAction extends AbstractAction
{
	private static final long serialVersionUID = 1L;

	private UserService userService;
	private String name;
	private String password;

	@Override
	public String execute() throws Exception
	{
		System.out.println("name=>" + name + ",password=>" + password);
		User user = userService.getUserByNameAndPassword(name, password);
		if(user == null)
		{
			addActionError("对不起,您输入的帐号/密码不正确.");
			return INPUT;
		}
		OnlineInfo onlineInfo = getOnlineInfo();
		onlineInfo.setUser(user);
		onlineInfo.setLoginTime(new Timestamp(System.currentTimeMillis()));
		return SUCCESS;
	}

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public String getPassword()
	{
		return password;
	}

	public void setPassword(String password)
	{
		this.password = password;
	}
}
